﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="grdListsGuests.ascx.cs" Inherits="GUESTSMANAGEMENT.View.WebUserControl1" %>
<%@ Register assembly="Coolite.Ext.Web" namespace="Coolite.Ext.Web" tagprefix="ext" %>
<%@ Register Src="~/View/ListsGuests/frmListGuests.ascx"  TagName="ListsGuests" TagPrefix="GMListsGuests" %>
<%--<%@ Register Src="~/View/ListsGuests/frmListsGuests.ascx" TagName="ListsGuests" TagPrefix="GMListsGuests" %>--%>

<script language="javascript">
    var formatTypeInvite = function(value) {
        switch (value) {
            case 1: return "Bônus Feminino"; break;
            case 2: return "Bônus Masculino"; break;
            case 3: return "Free Feminino"; break;
            case 4: return "Free Masculino"; break;
        }
    }
    


    var getListGuestId = function(grid, rowIndex, columnIndex, e) {
        var t = e.getTarget();
        var record = grid.getStore().getAt(rowIndex);
        var columnId = grid.getColumnModel().getColumnId(columnIndex);
        var columnValue = grid.getColumnModel().getDataIndex(3);
        var id = record.get(columnValue);
        alert(id);
        <%=txt_idGuestsList.ClientID %>.setValue(id);
    }
</script>

<ext:ScriptManagerProxy ID="ScriptManagerProxy" runat="server">
</ext:ScriptManagerProxy>

<ext:DesktopWindow ID="winGrdGuestsList" runat="server" Maximizable="false" Resizable="false" Collapsible="true" Icon="Group"  Title="Lista de Convidados" Width="600" Height="511">
    <Body>
        <ext:Hidden ID="txt_idGuestsList" runat="server"></ext:Hidden>
        <ext:Hidden ID="txt_idCdEvent" runat="server"></ext:Hidden>
        <ext:Hidden ID="txt_idCdUser" runat="server"></ext:Hidden>
        <ext:Store ID="listStore" runat="server" OnRefreshData="Refresh" RefreshAfterSaving="Auto">
            <Reader>
                <ext:JsonReader ReaderID="CDLISTGUEST">
                    <Fields>
                        <ext:RecordField Name="CDLISTGUESTS" />
                        <ext:RecordField Name="NMGUEST" />
                        <ext:RecordField Name="NMMAILGUEST" />
                        <ext:RecordField Name="FGTYPEINVITE" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
        </ext:Store>
        <ext:Panel ID="Panel1" runat="server" Width="590" Height="481">
            <Body>
                <ext:BorderLayout ID="BorderLayout1" runat="server">
                    <North>
                        <ext:FormPanel Width="600" Height="100" ID="FormPanel2" runat="server" Title="Dados do Evento" BodyStyle="padding:5px;" ButtonAlign="Right">
                            <Body>
                                <ext:ColumnLayout runat="server">
                                    <ext:LayoutColumn ColumnWidth=".4">
                                        <ext:Panel ID="LayoutColumn1" runat="server" Border="false">
                                            <Body>
                                                <ext:FormLayout ID="FormLayout2" runat="server">
                                                    <ext:Anchor>
                                                        <ext:DateField ID="eventDate" FieldLabel="Data" runat="server" AllowBlank="false" Width="100" BlankText="Data é requerido!" >
                                                            <AjaxEvents>
                                                                <Select OnEvent="EnventDateSelected">
                                                                </Select>
                                                            </AjaxEvents>
                                                        </ext:DateField>
                                                    </ext:Anchor>    
                                                </ext:FormLayout>
                                            </Body>
                                        </ext:Panel>
                                    </ext:LayoutColumn>
                                    <ext:LayoutColumn ColumnWidth=".6">
                                        <ext:Panel ID="LayoutColumn2" runat="server" Border="false">
                                            <Body>
                                                <ext:FormLayout ID="FormLayout3" runat="server">
                                                    <ext:Anchor>
                                                        <ext:TextField Width="200" ID="eventName" ReadOnly="true" FieldLabel="Evento" runat="server" MaxLength="255" />
                                                    </ext:Anchor>
                                                </ext:FormLayout>
                                            </Body>
                                        </ext:Panel>
                                    </ext:LayoutColumn>
                                    <ext:LayoutColumn ColumnWidth=".8">
                                        <ext:MultiField ID="MultiField1" runat="server" FieldLabel="Qt. Convites">
                                            <Fields>
                                                <ext:NumberField runat="server" ReadOnly="true" MaxValue="100" ID="Nqtbf" Width="98" Note="Bônus Fem." AllowBlank="false"></ext:NumberField>
                                                <ext:NumberField runat="server" ReadOnly="true" MaxValue="100" ID="Nqtbm" Width="99" Note="Bônus Masc." AllowBlank="false"></ext:NumberField>
                                                <ext:NumberField runat="server" ReadOnly="true" MaxValue="100" ID="Nqtff" Width="98" Note="Free Fem." AllowBlank="false"></ext:NumberField>
                                                <ext:NumberField runat="server" ReadOnly="true" MaxValue="100" ID="Nqtfm" Width="99" Note="Free Masc." AllowBlank="false"></ext:NumberField>
                                                <ext:TextField runat="server" ID="TimeList" ReadOnly="true" Note="Horário Limite" />
                                            </Fields>
                                        </ext:MultiField>
                                    </ext:LayoutColumn>
                                </ext:ColumnLayout>
                            </Body>
                        </ext:FormPanel>
                    </North>
                    <Center>
                        <ext:GridPanel ID="GridPanel1" 
                            runat="server"
                            StoreID="listStore"
                            Width="600"
                            Height="431"
                            StripeRows="true"
                            Enabled="false">
                            <TopBar>
                                <ext:Toolbar ID="ToolBar1" runat="server">
                                    <Items>
                                        <ext:ToolbarButton ID="btnNewListsGuests" runat="server" Icon="GroupAdd">
                                            <AjaxEvents>
                                                <Click OnEvent="SetListGuests" />
                                            </AjaxEvents>
                                            <ToolTips>
                                                <ext:ToolTip ID="ToolTipNewListsGuests" runat="server" Html="Novo Convidado"></ext:ToolTip>
                                            </ToolTips>
                                        </ext:ToolbarButton>
                                        <ext:ToolbarButton ID="btnExcluirListsGuests" runat="server" Icon="GroupDelete" Enabled="false">                     
                                            <AjaxEvents>
                                                <Click OnEvent="ConfirmDeleteListGuest">                                        
                                                    <Confirmation ConfirmRequest="true" 
                                                                  Title="Alerta"                                                                                                  
                                                                  BeforeConfirm="config.confirmation.message = alertMessage()"                                                       
                                                    />
                                                    <ExtraParams>
                                                        <ext:Parameter Name="id" Value="#{GridPanel1}.getSelectionModel().hasSelection() ? #{GridPanel1}.getSelectionModel().getSelected().data.CDLISTGUESTS : -1" Mode="Raw" />
                                                    </ExtraParams>                                        
                                                </Click>
                                            </AjaxEvents>
                                            <ToolTips>
                                                <ext:ToolTip ID="ToolTipDeleteListsGuests" runat="server" Html="Excluir Convidado"></ext:ToolTip>
                                            </ToolTips>
                                        </ext:ToolbarButton>
                                    </Items>
                                </ext:Toolbar>
                            </TopBar>
                            <ColumnModel ID="ColumnModel2" runat="server">
                                <Columns>
                                    <ext:Column ColumnID="NMGUEST" Header="Convidado" DataIndex="NMGUEST" Sortable="true" Width="200" />
                                    <ext:Column ColumnID="NMMAILGUEST" Header="E-mail" DataIndex="NMMAILGUEST" Sortable="true" Width="280" />
                                    <ext:Column ColumnID="TYPEINVITE" Header="Tipo de Convite" DataIndex="FGTYPEINVITE" Sortable="true" >
                                        <Renderer Fn="formatTypeInvite" />
                                    </ext:Column>
                                    <ext:Column ColumnID="CDLISTGUESTS" DataIndex="CDLISTGUESTS" Hidden="true" />
                                </Columns>
                            </ColumnModel>
                            <Listeners>
                                <CellDblClick />
                                <CellClick Fn="getListGuestId" />
                            </Listeners>
                            <SelectionModel>
                                <ext:RowSelectionModel ID="RowSelectionMode" runat="server">
                                    <Listeners>
                                        <RowSelect Handler="#{btnExcluirListsGuests}.enable();" />                             
                                        <RowDeselect Handler="if (!#{GridPanel1}.hasSelection()) {#{btnExcluirListsGuests}.disable();}" />                
                                    </Listeners>                       
                                </ext:RowSelectionModel>
                            </SelectionModel>
                            <BottomBar>
                                <ext:PagingToolBar ID="PagingToolBar1" runat="server" PageSize="15" StoreID="listStore" />
                            </BottomBar>
                        </ext:GridPanel>
                    </Center>
                </ext:BorderLayout>
            </Body>
        </ext:Panel>
       <GMListsGuests:ListsGuests ID="GMListsGuests" runat="server" />
    </Body>
</ext:DesktopWindow>